package cn.tedu.controller;

import cn.tedu.entity.Book;
import cn.tedu.service.BookService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author JokerQiu
 * @date 2021年12月16日 15:51
 */

@WebServlet("/bookList")
public class BookListServlet extends HttpServlet {
    private BookService bookService = new BookService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /*
         * 1.获取书籍数据
         * 2.返回书籍列表界面
         */
        //1. 获取数据数据
        List<Book> bookList = bookService.getBookList();
        //2.返回书籍列表
        req.setAttribute("bookList", bookList);
        req.getRequestDispatcher("bookList.jsp").forward(req, resp);
    }
}
